home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <bindings id="btbuttonBindings"
- xmlns="http://www.mozilla.org/xbl"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:xbl="http://www.mozilla.org/xbl">
-
- <binding id="btboommenubutton" extends="xul:box">
- <content>
- <xul:hbox>
- <xul:button type="menu"
- xbl:inherits="label">
- <xul:menupopup anonid="btboommenubutton-popup">
- <children/>
- </xul:menupopup>
- </xul:button>
- </xul:hbox>
- </content>
- <handlers>
- <handler event="command">
- <![CDATA[
- var subject = {};
- subject.wrappedJSObject = this.brandObject;
- this.observerService.notifyObservers(subject, "brandthunder", event.originalTarget.id);
- if (event.originalTarget.hasAttribute("boom")) {
- this.btPrefBranch.setCharPref("currentBoom", event.originalTarget.getAttribute("boom"));
- }
- ]]>
- </handler>
- <handler event="popupshowing">
- <![CDATA[
- switch (event.originalTarget.getAttribute("anonid")) {
- case "btboommenubutton-popup":
- var currentBoom = this.btPrefBranch.getCharPref("currentBoom");
- for (let i= event.originalTarget.childNodes.length - 1; i >= 0; i--) {
- var menuitem = event.originalTarget.childNodes.item(i);
- if (menuitem.getAttribute("boom") == currentBoom) {
- menuitem.setAttribute("checked", "true");
- } else {
- menuitem.setAttribute("checked", "false");
- }
- }
- break;
- }
- ]]>
- </handler>
- </handlers>
- <implementation>
- <constructor>
- <![CDATA[
- this.observerService = Components.classes["@mozilla.org/observer-service;1"]
- .getService(Components.interfaces.nsIObserverService)
- if (this.hasAttribute('btBoomBundle')) {
- this.btBoomBundle = document.getElementById(this.getAttribute('btBoomBundle'));
- }
- if (this.hasAttribute('btClientBundle')) {
- this.btClientBundle = document.getElementById(this.getAttribute('btClientBundle'));
- }
- if (this.hasAttribute('brand')) {
- this.brandObject = BrandThunder.clients[this.getAttribute('brand')];
- }
-
- if (this.brandObject) {
- this.btPrefBranch = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService)
- .getBranch("extensions.brandthunder.");
- }
- if ((this.btBoomBundle) || (this.btClientBundle)) {
- var label = this.getString(this.id + ".label");
- if (label) {
- this.setAttribute("label", label);
- }
- var menupopup = getAnonymousElementByAttribute(this, "anonid", "btboommenubutton-popup");
- if (menupopup.childNodes.length == 0) {
- var i = 1;
- var menuitem;
- for (var boom in this.brandObject.booms) {
- menuitem = document.createElement("menuitem");
- menuitem.setAttribute("label", brandObject.booms[boom]);
- menuitem.setAttribute("id", this.id + "-" + i);
- menuitem.setAttribute("boom", boom);
- menuitem.setAttribute("type", "checkbox");
- menupopup.appendChild(menuitem);
- i++;
- }
- }
- }
- ]]>
- </constructor>
- <destructor>
- </destructor>
- <field name="btPrefBranch"/>
- <field name="brandObject"/>
- <field name="btBoomBundle"/>
- <field name="btClientBundle"/>
- <field name="observerService"/>
- <method name="getString">
- <parameter name="id"/>
- <body>
- <![CDATA[
- var string;
- if (this.btBoomBundle) {
- try {
- string = this.btBoomBundle.getString(id);
- } catch(ex) {
- }
- }
- if (!string) {
- try {
- string = this.btClientBundle.getString(id);
- } catch(ex) {
- }
- }
- return string;
- ]]>
- </body>
- </method>
- </implementation>
- </binding>
- </bindings>
-